<h2>Save</h2>

<div fxLayout="row" fxLayoutAlign="start center" fxLayoutGap="1rem">
  <nz-button-group>
    <button nz-button nzType="primary" (click)="ms.save()">
      <span>Save</span>
    </button>
    <button nz-button nzType="default" (click)="ms.loadFromLocalStorage()">
      <span>Load</span>
    </button>
    <button
      nz-button
      nzDanger
      nz-popconfirm
      nzPopconfirmTitle="This is irreversible, Are you sure?"
      (nzOnConfirm)="ms.clear()"
    >
      <span>Clear</span>
    </button>
  </nz-button-group>

  <div *ngIf="ms.playFabId !== ''">
    <nz-button-group class="play-fab-buttons">
      <button nz-button nzType="primary" (click)="ms.saveToPlayFab()">
        <span>Save PlayFab</span>
      </button>
      <button nz-button nzType="default" (click)="ms.loadPlayFab()">
        <span>Load PlayFab</span>
      </button>
    </nz-button-group>
  </div>
</div>

<textarea nz-input [(ngModel)]="exp"></textarea>
<nz-button-group>
  <button nz-button nzType="primary" (click)="export()">
    <span>Export</span>
  </button>
  <button nz-button nzType="default" (click)="import()">
    <span>Import</span>
  </button>
  <button
    nz-button
    nzType="primary"
    (click)="download()"
    [disabled]="exp === ''"
  >
    <span>Download</span>
  </button>
</nz-button-group>

<ng-container *ngIf="!ms.kongregate">
  <br /><br />
  <h2>PlayFab</h2>
  <nz-tabset>
    <nz-tab nzTitle="Log in">
      <app-playfab-email [type]="1"></app-playfab-email>
    </nz-tab>
    <nz-tab nzTitle="Register">
      <app-playfab-email [type]="2"></app-playfab-email>
    </nz-tab>
    <nz-tab nzTitle="Forgot password">
      <app-playfab-email [type]="3"></app-playfab-email>
    </nz-tab>
  </nz-tabset>
</ng-container>

<br />
<span *ngIf="ms.lastSave > 0"
  >Last Local Save: {{ ms.lastSave | date: "medium" }}</span
>
<br />
<span *ngIf="ms.lastPlayFabSave > 0"
  >Last PlayFab Save: {{ ms.lastPlayFabSave | date: "medium" }}</span
>
<p>
  Game auto save on local storage every minute. Save on PlayFab every 3 minutes.
  <br />Data may be cleared from PlayFab's servers.
</p>
<a
  href="https://scorzy.github.io/IdleSpace2/assets/changelog.txt"
  target="_blank"
>
  Changelog
</a>
